n=(int(input()))
arr=list(map(int,input().rstrip().split()))
s=""
for e in range(n):
if arr[e]!=0 and e<n-1:
o=arr[e]
for ee in range(o):
if arr[e]!=1:
s=s+"PRL"
arr[e]-=1
else:
s=s+"PR"
arr[e]-=1
elif arr[e]==0 and e<n-1:
s=s+"R"
elif(arr[e]!=0 and e==n-1):
o=arr[e]
for ee in range(o):
if arr[e]!=1:
s=s+"PLR"
arr[e]-=1
else:
s=s+"P"
print(s)
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int t[n];
long long s=0;
for(int i=0;i<n;i++){
int a;
cin>>a;
t[i]=a;
s+=a;
}
int k=0;
int j=0;
bool test=true;
while(s!=0){
if(k==0){
if((t[j]!=0)&&(test)){
cout<<"P";
s--;
test=false;
t[j]=t[j]-1;
}
else if(j!=n-1){
cout<<"R";
test=true;
j++;
}
else{
k=1;
test=false;
}
}
else{
if((t[j]!=0)&&(test)){
cout<<"P";
s--;
t[j]=t[j]-1;
test=false;
}
else if(j!=0){
cout<<"L";
test=true;
j--;
}
else{
k=0;
test=false;
}
}
}
}
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |